package models;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.OneToMany;

import play.data.validation.Required;
import play.db.jpa.Model;

/**
 * Class for table Author.
 * @author Elisa
 */
@Entity
public class Author extends Model {

	@Required
	public String name;
	public String firstname;
	@Required
	public Integer type; // 1: Auteur, 2: Dessinateur, 3: Couleur (AuthorTypeEnum)
	
	
	@OneToMany(mappedBy = "author")
	public List<Book> books = new ArrayList<Book>();
	
	public Author(final String name, final String firstname, final Integer type) {
		this.name = name;
		this.firstname = firstname;
		this.type = type;
	}
	
	
	public String getCompletename() {
		return firstname + " " + name;
	}
	
	
}
